/**
 *
 *  @author ala
 *  @date 2024-09-20 18:50
 */
package main

import (
	"container/heap"
	_ "container/heap"
	"fmt"
)

func main() {
	//pq := &tools.PriorityQueue{
	//	&dto.Student{
	//		Name: "1111", Age: 100, Sex: dto.Man,
	//	},
	//	&dto.Student{
	//		Name: "2222", Age: 2, Sex: dto.Woman,
	//	},
	//}
	//heap.Init(pq)
	//fmt.Println(*pq)
	//s := &dto.Student{Name: "3333", Age: 3, Sex: dto.Man}
	//heap.Push(pq, s)
	//fmt.Println(*pq)
	//fmt.Println(heap.Pop(pq).(*dto.Student).Name)

	//class := dto.Class{
	//	Students: &dto.StudentAges{&dto.Student{Name: "1111", Age: 10}},
	//}
	//heap.Push(class.Students, &dto.Student{Name: "2222", Age: 20})
	//s := heap.Pop(class.Students).(*dto.Student)
	//fmt.Println(s)

	items := Items{}
	heap.Push(&items, []int{0, 0})
	heap.Push(&items, []int{1, 1})
	fmt.Println(heap.Pop(&items))
	fmt.Println(heap.Pop(&items))
	fmt.Println(len(items))
}

type Items [][]int

func (i *Items) Len() int { return len(*i) }
func (items *Items) Less(i, j int) bool {
	return (*items)[i][0]*(*items)[i][1] < (*items)[j][0]*(*items)[j][0]
}
func (items *Items) Swap(i, j int) {
	(*items)[i][0], (*items)[i][1], (*items)[j][0], (*items)[j][1] = (*items)[j][0], (*items)[j][1], (*items)[i][0], (*items)[i][1]
}
func (items *Items) Push(x interface{}) { *items = append(*items, x.([]int)) }
func (items *Items) Pop() interface{} {
	_items, n := *items, len(*items)
	last := _items[n-1]
	*items = _items[0 : n-1]
	return last
}
